<?php

namespace App\Services\Admin;
use Illuminate\Support\Facades\Log;
use App\Models\Config;

class ConfigService extends AdminService{


    /**
     * 获取列表
     * @param [type] $page
     * @param [type] $per_page
     * @method getList
     * @author chengzhigang<1256699215@qq.com>
     */
    public function getList($page,$per_page){
        try{
            $data = Config::from('config_info as a')->leftJoin('config_type as b','a.type_id','=','b.id')->select('a.*','b.name as type')->orderBy('b.sort','desc')->orderBy('sort','desc')->paginate($per_page,['*'],'page',$page)->toArray();
            return ['status'=>1,'msg'=>'请求成功','data'=>$data];
        }catch(\Exception $e){
            Log::info($e->getCode());
            Log::info($e->getFile());
            Log::info($e->getLine());
            Log::info('角色列表：' . $e->getMessage());
            writeErrorLog($e);
            return ['status' => 2, 'msg' => config('const.error'), 'data' => []];
        }
    }
}
